<?php 

require_once('getconfig.php');

Class Model_sellproperty extends Dbo_DbManager
 {
	protected $n_slno;
	protected $n_id;
	protected $d_date;
	protected $c_property_id;
	protected $c_property_type;
	protected $n_bedrooms;
	protected $n_bathrooms;	
	protected $c_district;
	protected $c_state;
	protected $c_location;
	protected $c_titile;
	protected $c_discription;
	protected $c_building_size;
	protected $c_building_unit;
	protected $c_plot_size;
	protected $c_plot_unit;	
	protected $c_builtin_year;	
	protected $c_expected_price;
	protected $c_expected_price_unit;
	protected $c_negotiable;
	protected $c_distance_airport;
	protected $c_distance_railway;
	protected $c_distance_hospital;
	protected $c_distance_school;
	protected $c_distance_city;	
	
	protected $c_twowheeleraccess;	
	protected $c_fourwheeleraccess;	
	protected $c_gatedproperty;	
	protected $c_residecolony;	
	protected $c_ownership;
	
	protected $c_first_name;	
	protected $c_contact_state;	
	protected $c_contact_address;	
	protected $c_contact_pin;	
	protected $c_contact_email;	
	protected $c_contact_mobil;		
		
	
	protected $propcount;

    public function __construct($createCon=TRUE){
 	  parent::__construct($createCon);
 	}
	
	public function getslno()
	{
		return  $this->n_slno;
	}	
	public function getuserid()
	{
		return  $this->n_id;
	}
	public function getDateofpost()
	{
		return  $this->d_date;
	}			
	public function getPropid()
	{
		return  $this->c_property_id;
	}
	public function getProptype()
	{
		return  $this->c_property_type;
	}	
	public function getBedrooms()
	{
		return  $this->n_bedrooms;
	}
	public function getBathrooms()
	{
		return  $this->n_bathrooms;
	}		
	public function getPropdistrict()
	{
		return  $this->c_district;
	}	
	public function getPropState()
	{
		return  $this->c_state;
	}		
	public function getProplocation()
	{
		return  $this->c_location;
	}	
	public function getProptitile()
	{
		return  $this->c_titile;
	}	
	public function getDiscription()
	{
		return  $this->c_discription;
	}	
	public function getPropsize()
	{
		return  $this->c_building_size;
	}
	public function getPropsizeunit()
	{
		return  $this->c_building_unit;
	}
	public function getPlotsize()
	{
		return  $this->c_plot_size;
	}
	public function getPlotsizeunit()
	{
		return  $this->c_plot_unit;
	}
	public function getBuiltyear()
	{
		return  $this->c_builtin_year;
	}
	public function getExpectedprice()
	{
		return  $this->c_expected_price;
	}	
	public function getExpectedpriceunit()
	{
		return  $this->c_expected_price_unit;
	}	
	public function getnegotiable()
	{
		return  $this->c_negotiable;
	}	
	public function getDistairport()
	{
		return  $this->c_distance_airport;
	}
	public function getDistrailway()
	{
		return  $this->c_distance_railway;
	}
	public function getDisthospital()
	{
		return  $this->c_distance_hospital;
	}
	public function getDistschool()
	{
		return  $this->c_distance_school;
	}
	public function getDistcity()
	{
		return  $this->c_distance_city;
	}
	public function getTwoweeler()
	{
		return  $this->c_twowheeleraccess;
	}
	public function getFourwheeler()
	{
		return  $this->c_fourwheeleraccess;
	}	
	public function getGatedprop()
	{
		return  $this->c_gatedproperty;
	}	
	public function getResidential()
	{
		return  $this->c_residecolony;
	}		
	public function getOwnership()
	{
		return  $this->c_ownership;
	}				

		
	public function getName()
	{
		return  $this->c_first_name;
	}	
	public function getContstate()
	{
		return  $this->c_contact_state;
	}	
/*	public function getContaddress()
	{
		return  $this->c_contact_address;
	}	
	public function getContpin()
	{
		return  $this->c_contact_pin;
	}	
	public function getContemail()
	{
		return  $this->c_contact_email;
	}	
	public function getContmobil()
	{
		return  $this->c_contact_mobil;
	}												
*/	
//--------seting-------
	public function setslno($n_slno)
	{
		$this->n_slno=$n_slno;
	}
	public function setuserid($n_id)
	{
		$this->n_id=$n_id;
	}
	public function setDateofpost($d_date)
	{
		$this->d_date=$d_date;
	}		
	public function setPropid($c_property_id)
	{
		$this->c_property_id=$c_property_id;
	}
	public function setProptype($c_property_type)
	{
		$this->c_property_type=$c_property_type;
	}	
	public function setBedrooms($n_bedrooms)
	{
		$this->n_bedrooms=$n_bedrooms;
	}
	public function setBathrooms($n_bathrooms)
	{
		$this->n_bathrooms=$n_bathrooms;
	}		
 	public function setPropdistrict($c_district)
	{
		$this->c_district=$c_district;
	}	
	public function setState($c_state)
	{
		$this->c_state=$c_state;
	}	
	public function setProplocation($c_location)
	{
		$this->c_location=$c_location;
	}		
	public function setProptitile($c_titile)
	{
		$this->c_titile=$c_titile;
	}	
	public function setDiscription($c_discription)
	{
		$this->c_discription=$c_discription;
	}		
	public function setPropsize($c_building_size)
	{
		$this->c_building_size=$c_building_size;
	}
	public function setPropsizeunit($c_building_unit)
	{
		$this->c_building_unit=$c_building_unit;
	}
	public function setPlotsize($c_plot_size)
	{
		$this->c_plot_size=$c_plot_size;
	}
	public function setplotsizeunit($c_plot_unit)
	{
		$this->c_plot_unit=$c_plot_unit;
	}			
	public function setBuiltyear($c_builtin_year)
	{
		$this->c_builtin_year=$c_builtin_year;
	}	
	public function setExpectedprice($c_expected_price)
	{
		$this->c_expected_price=$c_expected_price;
	}	
	public function setExpectedpriceunit($c_expected_price_unit)
	{
		$this->c_expected_price_unit=$c_expected_price_unit;
	}
	public function setNegotiable($c_negotiable)
	{
		$this->c_negotiable=$c_negotiable;
	}	
	public function setDistairport($c_distance_airport)
	{
		$this->c_distance_airport=$c_distance_airport;
	}
	public function setDistrailway($c_distance_railway)
	{
		$this->c_distance_railway=$c_distance_railway;
	}
	public function setDisthospital($c_distance_hospital)
	{
		$this->c_distance_hospital=$c_distance_hospital;
	}
	public function setDistschool($c_distance_school)
	{
		$this->c_distance_school=$c_distance_school;
	}	
	public function setDistcity($c_distance_city)
	{
		$this->c_distance_city=$c_distance_city;
	}	
	
	
	public function setTwoweeler($c_twowheeleraccess)
	{
		$this->c_twowheeleraccess=$c_twowheeleraccess;
	}	
	public function setFourwheeler($c_fourwheeleraccess)
	{
		$this->c_fourwheeleraccess=$c_fourwheeleraccess;
	}	

	public function setGatedprop($c_gatedproperty)
	{
		$this->c_gatedproperty=$c_gatedproperty;
	}	

	public function setResidential($c_residecolony)
	{
		$this->c_residecolony=$c_residecolony;
	}	
	
	public function setOwnership($c_ownership)
	{
		$this->c_ownership=$c_ownership;
	}
		
	public function setName($c_first_name)
	{
		$this->c_first_name=$c_first_name;
	}	
	public function setContstate($c_contact_state)
	{
		$this->c_contact_state=$c_contact_state;
	}		
	public function setContaddress($c_contact_address)
	{
		$this->c_contact_address=$c_contact_address;
	}	
	public function setContpin($c_contact_pin)
	{
		$this->c_contact_pin=$c_contact_pin;
	}	
	public function setContemail($c_contact_email)
	{
		$this->c_contact_email=$c_contact_email;
	}	
	public function setContmobil($c_contact_mobil)
	{
		$this->c_contact_mobil=$c_contact_mobil;
	}		
	
	public function setpropcount($propcount)
	{
		$this->count=$propcount;
	}	
	
									
//---------------------------------------------------------//	
	public function write()
	{
		//echo "haiii";
		$objDbManager = new Dbo_DbManager();
		$intuserid=$objDbManager->write($this);	
	}


	public static function delete($intuserid)
	{
		$objDbManager = new Dbo_DbManager();
		return $objDbManager->remove($intuserid,__CLASS__);
	}


	public static function get($intuserid=NULL)
	{
		$arrRes=array();
		$objDbManager = new Dbo_DbManager();
		$arrModel_sellproperty = $objDbManager->fetch(array('intuserid' => $intuserid),__CLASS__);
		if(count($arrModel_sellproperty)>0) {
			foreach($arrModel_sellproperty as $arrNew) { 
				$objUser = self::build($arrNew);
				$arrRes[]=$objUser;
			}
		}
		return $arrRes;
	}


	public function getoncondition()
	{
		$arrRes=array();
		$objDbManager = new Dbo_DbManager();
		$arrModel_sellproperty = $objDbManager->fetchOnCondition($this,TRUE);
		if(count($arrModel_sellproperty)>0) {
			foreach($arrModel_sellproperty as $arrNew) { 
				$objUser = self::build($arrNew);
				$arrRes[]=$objUser;
			}
		}
		return $arrRes;
	}


	public static function build(array $arrModel_sellproperty)
	{
		$Model_sellproperty = new Model_sellproperty(FALSE);
		@$Model_sellproperty->setslno($arrModel_sellproperty['n_slno']);
		@$Model_sellproperty->setuserid($arrModel_sellproperty['n_id']);
		@$Model_sellproperty->setDateofpost($arrModel_sellproperty['d_date']);		
		@$Model_sellproperty->setPropid($arrModel_sellproperty['c_property_id']);
		@$Model_sellproperty->setProptype($arrModel_sellproperty['c_property_type']);
		@$Model_sellproperty->setBedrooms($arrModel_sellproperty['n_bedrooms']);
		@$Model_sellproperty->setBathrooms($arrModel_sellproperty['n_bathrooms']);
		@$Model_sellproperty->setPropdistrict($arrModel_sellproperty['c_district']);
		@$Model_sellproperty->setState($arrModel_sellproperty['c_state']);
		@$Model_sellproperty->setProplocation($arrModel_sellproperty['c_location']);
		@$Model_sellproperty->setProptitile($arrModel_sellproperty['c_titile']);
		@$Model_sellproperty->setDiscription($arrModel_sellproperty['c_discription']);
		@$Model_sellproperty->setPropsize($arrModel_sellproperty['c_building_size']);
		@$Model_sellproperty->setPropsizeunit($arrModel_sellproperty['c_building_unit']);
		@$Model_sellproperty->setPlotsize($arrModel_sellproperty['c_plot_size']);
		@$Model_sellproperty->setplotsizeunit($arrModel_sellproperty['c_plot_unit']);
		@$Model_sellproperty->setBuiltyear($arrModel_sellproperty['c_builtin_year']);
		@$Model_sellproperty->setExpectedprice($arrModel_sellproperty['c_expected_price']);
		@$Model_sellproperty->setExpectedpriceunit($arrModel_sellproperty['c_expected_price_unit']);
		@$Model_sellproperty->setNegotiable($arrModel_sellproperty['c_negotiable']);
		@$Model_sellproperty->setDistairport($arrModel_sellproperty['c_distance_airport']);
		@$Model_sellproperty->setDistrailway($arrModel_sellproperty['c_distance_railway']);
		@$Model_sellproperty->setDisthospital($arrModel_sellproperty['c_distance_hospital']);
		@$Model_sellproperty->setDistschool($arrModel_sellproperty['c_distance_school']);
		@$Model_sellproperty->setTwoweeler($arrModel_sellproperty['c_twowheeleraccess']);
		@$Model_sellproperty->setFourwheeler($arrModel_sellproperty['c_fourwheeleraccess']);
		@$Model_sellproperty->setGatedprop($arrModel_sellproperty['c_gatedproperty']);
		@$Model_sellproperty->setResidential($arrModel_sellproperty['c_residecolony']);
		@$Model_sellproperty->setOwnership($arrModel_sellproperty['c_ownership']);

		
		@$Model_sellproperty->setName($arrModel_sellproperty['c_first_name']);
		@$Model_sellproperty->setContstate($arrModel_sellproperty['c_contact_state']);
		@$Model_sellproperty->setContaddress($arrModel_sellproperty['c_contact_address']);
		@$Model_sellproperty->setContpin($arrModel_sellproperty['c_contact_pin']);
		@$Model_sellproperty->setContemail($arrModel_sellproperty['c_contact_email']);
		@$Model_sellproperty->setContmobil($arrModel_sellproperty['c_contact_mobil']);

		return $Model_sellproperty;
 	 }
	 
	public static function build_count(array $arrModel_sellproperty)
	{
		$Model_sellproperty = new Model_sellproperty(FALSE);
		@$Model_sellproperty->setcount($arrModel_sellproperty['propcount']);
		return $Model_sellproperty;
 	 }	 

	public static function build_sell_property(array $arrModel_sellproperty)
	{
		$Model_sellproperty = new Model_sellproperty(FALSE);		
		@$Model_sellproperty->setuserid($arrModel_sellproperty['n_id']);		
		return $Model_sellproperty;
 	 }	 
	public static function build_sell_property_image(array $arrModel_sellproperty)
	{
		$Model_sellproperty = new Model_sellproperty(FALSE);		
		@$Model_sellproperty->setImagepath($arrModel_sellproperty['c_image_path']);
		return $Model_sellproperty;
 	 }		 
     public function getlastinsertedid(){
		$objDbManager = new Dbo_DbManager ();
		$userid=$objDbManager->getMaxId($this,"max","intuserid");
		return $userid;
	}
	
	public static function get_sell_property_index_HV(){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE c_property_type='PROP1' OR c_property_type='PROP2' ";
	//	echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
	public static function get_sell_property_index_HP(){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE c_property_type='PROP6'  or c_property_type='PROP5'";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	
	public static function get_sell_property_index_FA(){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE c_property_type='PROP3'";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}		
	
	public static function get_property_details($propid){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from sellproperty where c_property_id='$propid' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
//district wise functions	
	public static function get_property_district($district){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from sellproperty where c_district='$district' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}		
	public static function get_sell_property_district_HV($district){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE (c_property_type='PROP1' OR c_property_type='PROP2') and  c_district='$district' ";
	//	echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	
	public static function get_sell_property_district_HP($district){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE c_property_type='PROP6' or c_property_type='PROP5'  and  c_district='$district' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	
	public static function get_sell_property_district_FA($district){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE c_property_type='PROP3' and  c_district='$district' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
		
//end district wise functions		

	
	
	public static function get_hotproperty(){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from sellproperty";
		echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}		
	
//indivigual property details
	public static function get_sell_property_individual($proptype){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE c_property_type='$proptype' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}		
//indivigual property details
	public static function get_sell_property_individualid($id){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM sellproperty WHERE n_id='$id' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	
	//cout for district	
	public static function get_property_districtcount($district){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT COUNT(1) COUNT FROM sellproperty WHERE c_district='$district' ";
		//echo $qry;
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build_count( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	
		
	public static function getregusers(){
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from tbluser where intuserid>1";
		$arrModel_sellproperty=$objDbManager->runquery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
	public static function getreguserslimit($lowerlimit,$upperlimit){
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from tbluser where intuserid>1 LIMIT $lowerlimit,$upperlimit";
		$arrModel_sellproperty=$objDbManager->ExecuteQuery("$qry");
		if (count( $arrModel_sellproperty ) > 0) {
			foreach ( $arrModel_sellproperty as $arrNew ) {
				$objUser = self::build_sell_property_bclogin ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
	
	
    public  function __call($method, $arguments) {
    	
       if(count($arguments)>0){
       	   $sqlFunction=$arguments[0];
       	    $objDbManager = new Dbo_DbManager();
       	   return $objDbManager->runSqlFunctions(__CLASS__,array($method=>$sqlFunction));
       }
    }
 
	

 }
 ?>
